<template>
  <div class="loading">
    <van-loading type="spinner" color="#1989fa" />授权中
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  mounted() {
    this.keyCheck();
  },
  methods: {
    keyCheck() {
      if (this.$route.query.key != undefined) {
        let key = this.$route.query.key;
        let member_id = this.$route.query.member_id;
        let member_avatar = this.$route.query.member_avatar;
        let member_name = this.$route.query.member_name;
        this.$store.dispatch("setUserKey", key);
        this.$store.dispatch("setMemberId", member_id);
        this.$store.dispatch("setMemberAvatar", member_avatar);
        this.$store.dispatch("setMemberName", member_name);
        this.goBack();
      }
    },
    goBack() {
      let forward = JSON.parse(localStorage.getItem("forward")) || {};
      if (forward.name) {
        this.$router.push({
          name: forward.name,
          query: forward.query,
        });
      } else {
        this.$router.push({
          name: "index",
        });
      }
    },
  },
};
</script>

<style lang="css" scoped>
.loading {
  background: #fff;
  min-height: 100vh;
  text-align: center;
}
.loading >>> .van-loading {
  margin: 100px auto 10px;
}
</style>